.class public Lcom/renren/api/connect/android/share/ShareHelper;
.super Ljava/lang/Object;
.source "ShareHelper.java"


# static fields
.field public static final PUBLISH_STATUS_PERMISSIONS:[Ljava/lang/String;


# instance fields
.field private renren:Lcom/renren/api/connect/android/Renren;


# direct methods
.method static constructor <clinit>()V
    .locals 3

    .prologue
    .line 22
    const/4 v0, 0x1

    new-array v0, v0, [Ljava/lang/String;

    const/4 v1, 0x0

    const-string v2, "publish_share"

    aput-object v2, v0, v1

    sput-object v0, Lcom/renren/api/connect/android/share/ShareHelper;->PUBLISH_STATUS_PERMISSIONS:[Ljava/lang/String;

    .line 18
    return-void
.end method

.method public constructor <init>(Lcom/renren/api/connect/android/Renren;)V
    .locals 0
    .parameter "renren"

    .prologue
    .line 35
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 36
    iput-object p1, p0, Lcom/renren/api/connect/android/share/ShareHelper;->renren:Lcom/renren/api/connect/android/Renren;

    .line 37
    return-void
.end method


# virtual methods
.method public publish(Lcom/renren/api/connect/android/share/ShareSetRequestParam;)Lcom/renren/api/connect/android/share/ShareSetResponseBean;
    .locals 12
    .parameter "status"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/renren/api/connect/android/exception/RenrenException;,
            Ljava/lang/Throwable;
        }
    .end annotation

    .prologue
    .line 51
    iget-object v8, p0, Lcom/renren/api/connect/android/share/ShareHelper;->renren:Lcom/renren/api/connect/android/Renren;

    invoke-virtual {v8}, Lcom/renren/api/connect/android/Renren;->isAccessTokenValid()Z

    move-result v8

    if-nez v8, :cond_0

    .line 52
    const-string v0, "AccessToken is not valid."

    .line 53
    .local v0, errorMsg:Ljava/lang/String;
    new-instance v8, Lcom/renren/api/connect/android/exception/RenrenException;

    const/4 v9, -0x4

    invoke-direct {v8, v9, v0, v0}, Lcom/renren/api/connect/android/exception/RenrenException;-><init>(ILjava/lang/String;Ljava/lang/String;)V

    throw v8

    .line 58
    .end local v0           #errorMsg:Ljava/lang/String;
    :cond_0
    if-nez p1, :cond_1

    .line 59
    const-string v0, "The parameter is null."

    .line 60
    .restart local v0       #errorMsg:Ljava/lang/String;
    new-instance v8, Lcom/renren/api/connect/android/exception/RenrenException;

    .line 61
    const/4 v9, -0x1

    .line 60
    invoke-direct {v8, v9, v0, v0}, Lcom/renren/api/connect/android/exception/RenrenException;-><init>(ILjava/lang/String;Ljava/lang/String;)V

    throw v8

    .line 67
    .end local v0           #errorMsg:Ljava/lang/String;
    :cond_1
    :try_start_0
    invoke-virtual {p1}, Lcom/renren/api/connect/android/share/ShareSetRequestParam;->getParams()Landroid/os/Bundle;

    move-result-object v3

    .line 68
    .local v3, params:Landroid/os/Bundle;
    iget-object v8, p0, Lcom/renren/api/connect/android/share/ShareHelper;->renren:Lcom/renren/api/connect/android/Renren;

    invoke-virtual {v8, v3}, Lcom/renren/api/connect/android/Renren;->requestJSON4AccessToken(Landroid/os/Bundle;)Ljava/lang/String;
    :try_end_0
    .catch Lcom/renren/api/connect/android/exception/RenrenException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/lang/RuntimeException; {:try_start_0 .. :try_end_0} :catch_1

    move-result-object v5

    .line 77
    .local v5, response:Ljava/lang/String;
    const-string v8, "json"

    invoke-static {v5, v8}, Lcom/renren/api/connect/android/Util;->parseRenrenError(Ljava/lang/String;Ljava/lang/String;)Lcom/renren/api/connect/android/exception/RenrenError;

    move-result-object v6

    .line 78
    .local v6, rrError:Lcom/renren/api/connect/android/exception/RenrenError;
    if-eqz v6, :cond_2

    .line 79
    new-instance v8, Lcom/renren/api/connect/android/exception/RenrenException;

    invoke-direct {v8, v6}, Lcom/renren/api/connect/android/exception/RenrenException;-><init>(Lcom/renren/api/connect/android/exception/RenrenError;)V

    throw v8

    .line 69
    .end local v3           #params:Landroid/os/Bundle;
    .end local v5           #response:Ljava/lang/String;
    .end local v6           #rrError:Lcom/renren/api/connect/android/exception/RenrenError;
    :catch_0
    move-exception v7

    .line 70
    .local v7, rre:Lcom/renren/api/connect/android/exception/RenrenException;
    invoke-virtual {v7}, Lcom/renren/api/connect/android/exception/RenrenException;->getMessage()Ljava/lang/String;

    move-result-object v8

    invoke-static {v8}, Lcom/renren/api/connect/android/Util;->logger(Ljava/lang/String;)V

    .line 71
    throw v7

    .line 72
    .end local v7           #rre:Lcom/renren/api/connect/android/exception/RenrenException;
    :catch_1
    move-exception v4

    .line 73
    .local v4, re:Ljava/lang/RuntimeException;
    invoke-virtual {v4}, Ljava/lang/RuntimeException;->getMessage()Ljava/lang/String;

    move-result-object v8

    invoke-static {v8}, Lcom/renren/api/connect/android/Util;->logger(Ljava/lang/String;)V

    .line 74
    new-instance v8, Ljava/lang/Throwable;

    invoke-direct {v8, v4}, Ljava/lang/Throwable;-><init>(Ljava/lang/Throwable;)V

    throw v8

    .line 82
    .end local v4           #re:Ljava/lang/RuntimeException;
    .restart local v3       #params:Landroid/os/Bundle;
    .restart local v5       #response:Ljava/lang/String;
    .restart local v6       #rrError:Lcom/renren/api/connect/android/exception/RenrenError;
    :cond_2
    :try_start_1
    new-instance v2, Lorg/json/JSONObject;

    invoke-direct {v2, v5}, Lorg/json/JSONObject;-><init>(Ljava/lang/String;)V

    .line 83
    .local v2, json:Lorg/json/JSONObject;
    new-instance v8, Lcom/renren/api/connect/android/share/ShareSetResponseBean;

    invoke-direct {v8, v5}, Lcom/renren/api/connect/android/share/ShareSetResponseBean;-><init>(Ljava/lang/String;)V
    :try_end_1
    .catch Lorg/json/JSONException; {:try_start_1 .. :try_end_1} :catch_2

    return-object v8

    .line 84
    .end local v2           #json:Lorg/json/JSONObject;
    :catch_2
    move-exception v1

    .line 85
    .local v1, je:Lorg/json/JSONException;
    invoke-virtual {v1}, Lorg/json/JSONException;->getMessage()Ljava/lang/String;

    move-result-object v8

    invoke-static {v8}, Lcom/renren/api/connect/android/Util;->logger(Ljava/lang/String;)V

    .line 86
    new-instance v8, Lcom/renren/api/connect/android/exception/RenrenException;

    .line 87
    const/4 v9, -0x5

    invoke-virtual {v1}, Lorg/json/JSONException;->getMessage()Ljava/lang/String;

    move-result-object v10

    .line 88
    invoke-virtual {v1}, Lorg/json/JSONException;->getMessage()Ljava/lang/String;

    move-result-object v11

    .line 86
    invoke-direct {v8, v9, v10, v11}, Lcom/renren/api/connect/android/exception/RenrenException;-><init>(ILjava/lang/String;Ljava/lang/String;)V

    throw v8
.end method
